package com.xbh.management.controller;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xbh.common.web.core.Result;
import com.xbh.management.model.ManLoginLog;
import com.xbh.management.model.ManOperationLog;
import com.xbh.management.service.ManOperationLogService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;



/**
 * @program: management-center
 * @description:
 * @author: 许宝华
 * @create: 2021-12-15 10:13
 */

@RestController
@RequestMapping("/operation")
@Slf4j
public class ManOperationLogController {

    @Autowired
    private ManOperationLogService manOperationLogService;

    @PostMapping("/list")
    public Result list(@RequestBody JSONObject params) {
        Integer pageNum = params.getInteger("pageNum");
        Integer pageSize = params.getInteger("pageSize");
        LambdaQueryWrapper<ManOperationLog> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(ManOperationLog::getUserId, params.getLong("userId"));
        wrapper.orderByDesc(ManOperationLog::getCreateTime);
        Page<ManOperationLog> page = manOperationLogService.page(new Page<ManOperationLog>(pageNum, pageSize), wrapper);
        return Result.success(page);
    }
}
